package com.zhss.redis.list;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;

import java.util.stream.IntStream;

/**
 * @ClassName SplitPage
 * @Description TODO
 * @Author leejiliang
 * @DateTime 2021/9/23 22:05
 * @Version 1.0
 */
public class SplitPage {
	static Jedis jedis = new Jedis(new HostAndPort("121.4.79.149", 6379));
	private static String list_key = "content_titles";

	public static void add() {
		IntStream.rangeClosed(0, 30).forEach(i->{
			jedis.rpush(list_key, String.valueOf(i));
		});
	}

	public static void getPage(int page) {
		var startIndex = page * 10;
		var endIndex = ((page + 1) * 10-1);
		jedis.lrange(list_key, startIndex, endIndex).forEach(System.out::println);
	}

	public static void main(String[] args) {
//		add();
		getPage(3);

	}
}
